#ifndef	LIA_AUDIODEVICE_H
#define LIA_AUDIODEVICE_H

#include <LIA/liaCommon.h>

#define LIA_DEVICE_CHANNELS			2
#define LIA_DEVICE_SAMPLERATE		44100
#define	LIA_DEVICE_SAMPLEBYTES		2

#define	LIA_DEVICE_BLOCKSIZE		2048
#define LIA_DEVICE_BLOCKCOUNT		3
#define LIA_DEVICE_LAYERCOUNT		64

namespace Lia {

struct LayerInfo
{
	AudioSource* source;
	bool paused, loop;
	
	float volume[2];
	int samplePos;
	float rate;

	bool is3DSound;
	Float3 position3d;

	float monoRange;
	float volumeRange;
	float volume3dForL[2];
	float volume3dForR[2];
};

typedef unsigned int LiaHandle;
class LIA_API AudioDevice
{
public:
	static bool Open();
	static void Close();

	static void Play2d(LiaHandle layer, AudioSource* audio, bool loop=false);
	static void Play3d(LiaHandle layer, AudioSource* audio, const Float3& pos, 
					   bool loop=false, float volumeRange=0.5f, float monoRange=0.25f);
	
	static void Stop(LiaHandle layer);
	static void Pause(LiaHandle layer);
	static void Resume(LiaHandle layer);

	static void SetVolume(LiaHandle layer, float volume);
	static void SetPlaybackRate(LiaHandle layer, float rate);
	static void SetPlaybackPos(LiaHandle layer, int samplePos);
	static void Setposition3d(LiaHandle layer, const Float3& pos);

	static void SetListener(const Float3& pos, const Float3& lookAt, const Float3& up);
	static void SetMasterVolume(float channelL, float channelR);
};

}; // namespace Lia

#endif /* LIA_AUDIODEVICE_H */